﻿using System.Collections.Generic;

namespace AiFrame.InterfaceLib.Data.Access
{
    /// <summary>
    /// Describes a basic dao class with common functions.
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <typeparam name="ID"></typeparam>
    public interface IBasicDao<T, ID>
    {
        /// <summary>
        ///   Find all elements for the given type.
        ///   </summary><returns>The data objects.</returns>
        IList<T> FindAll();

        /// <summary>
        ///   Finds the object for the given ID.
        ///   </summary><param name="id">ID</param><returns>The data object.</returns>
        T FindByID(ID id);

        /// <summary>
        ///   Speichert das Datenobjekt oder aktualisiert es.
        ///   </summary>
        void SaveOrUpdate(T item);

        /// <summary>
        ///   Deletes the given item.
        ///   </summary><param name="item"></param>
        void Delete(T item);

        /// <summary>
        ///   Deletes the item with the given id.
        ///   </summary><param name="id"></param>
        void Delete(ID id);

        /// <summary>
        ///   Refreshes the given item.
        ///   </summary><param name="item"></param>
        void Refresh(T item);
    }
}
